package com.cat.greedyAlgorithm;

import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/rearrange-array-to-maximize-prefix-score/description/
 * @create 2025/8/21 15:07
 * @since JDK17
 */

public class Solution06 {
    public int maxScore(int[] nums) {
        Arrays.sort(nums);
        int ans = 0, sum = 0, n = nums.length;
        for (int i = 0; i < n; i++) {
            sum += nums[i];
            ans += sum > 0 ? 1 : 0;
        }
        return ans;
    }
}
